<template>
  <div class="container">
    <el-dialog
      :visible="showAudit"
      title="题目审核"
      width="29%"
      @close="btnCancel"
    >
      <el-form ref="roleForm" :model="roleForm">
        <el-form-item>
          <el-radio v-model="roleForm.chkState" label="2">通过</el-radio>
          <el-radio v-model="roleForm.chkState" label="3">拒绝</el-radio>
        </el-form-item>
        <el-form-item>
          <el-input
            v-model="roleForm.chkRemarks"
            style="width: 100%"
            placeholder="请输入审核意见"
            type="textarea"
            :rows="2"
          />
        </el-form-item>
      </el-form>

      <!-- 底部 -->
      <el-row slot="footer" type="flex" justify="end">
        <el-col :span="12">
          <el-button @click="btnCancel">取消</el-button>
          <el-button type="primary" @click="btnOK">确认</el-button>
        </el-col>
      </el-row>
    </el-dialog>
  </div>
</template>
<script>
import { choiceCheck } from '@/api/hmmm/questions' // 精选题库
export default {
  props: {
    rowAudit: {
      type: Object,
      default: () => {}
    },
    showAudit: {
      type: Boolean,
      default: false
    }
   
  },
  data () {
    return {
      // 专门接收表单数据
      roleForm: {
        chkState: '2',
        chkRemarks: ''
      }
    }
  },
  methods: {
    // 取消按钮
    btnCancel () {
      this.roleForm = {
        chkState: '2',
        chkRemarks: ''
      }
      this.$emit('update:showAudit', false)
    },
    // 确认按钮
    async btnOK () {
      // 确认按钮
      try {
        if (this.roleForm.chkRemarks.trim() === '') {
          return this.$message.warning('请输入审核意见')
        }
        await choiceCheck({ chkState: Number(this.roleForm.chkState), chkRemarks: this.roleForm.chkRemarks, id: this.rowAudit.id })
        this.$emit('update:showAudit', false)
        this.$parent.getChoice()
        this.$message({
          message: '审核成功!',
          type: 'success'
        })
      } catch (error) {
        console.log(error)
      }
    }
  }
}
</script>

<style scoped lang='scss'>
</style>
